package com.os.osframe.scaffold.domain;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

/**
 * Created by wangdc on 2015-4-26.
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class ScaffoldXmlField {
    @XmlAttribute(name="id")
    protected String filedId;//字段ID
    @XmlAttribute(name="name" )
    protected String filedName;//字段名称
    @XmlAttribute(name="type" )
    protected String filedType;//字段描述
    @XmlAttribute(name="length" )
    protected String filedLength;//字段长度
    @XmlAttribute
    protected String javaType;//java字段类型
    @XmlAttribute
    protected String required;//是否必填
    @XmlAttribute
    protected String foreignId;//关联外键ID字段 java
    @XmlAttribute
    protected String foreignName;//关联外键Name字段 java
    @XmlAttribute
    protected String selectType;//选择类型  select 下拉框 radio单选 checkbox 多选
    @XmlAttribute
    protected String dataSource;//数据来源 database 数据库 enums 枚举 diy自定义，该属性与selectType之后出现可缺省
    @XmlAttribute
    protected String mapping;//数据映射类型 OneToMany ManyToMany ManyToOne
    @XmlAttribute
    protected String joinTable;//级联表名
    @XmlAttribute
    protected String joinSourceField;//级联表源字段名
    @XmlAttribute
    protected String joinTargetField;//级联表目标字段名

    public String getFiledId() {
        return filedId;
    }

    public void setFiledId(String filedId) {
        this.filedId = filedId;
    }

    public String getFiledName() {
        return filedName;
    }

    public void setFiledName(String filedName) {
        this.filedName = filedName;
    }

    public String getFiledType() {
        return filedType;
    }

    public void setFiledType(String filedType) {
        this.filedType = filedType;
    }

    public String getFiledLength() {
        return filedLength;
    }

    public void setFiledLength(String filedLength) {
        this.filedLength = filedLength;
    }

    public String getJavaType() {
        return javaType;
    }

    public void setJavaType(String javaType) {
        this.javaType = javaType;
    }

    public String getRequired() {
        return required;
    }

    public void setRequired(String required) {
        this.required = required;
    }

    public String getForeignId() {
        return foreignId;
    }

    public void setForeignId(String foreignId) {
        this.foreignId = foreignId;
    }

    public String getForeignName() {
        return foreignName;
    }

    public void setForeignName(String foreignName) {
        this.foreignName = foreignName;
    }

    public String getSelectType() {
        return selectType;
    }

    public void setSelectType(String selectType) {
        this.selectType = selectType;
    }

    public String getDataSource() {
        return dataSource;
    }

    public void setDataSource(String dataSource) {
        this.dataSource = dataSource;
    }

    public String getMapping() {
        return mapping;
    }

    public void setMapping(String mapping) {
        this.mapping = mapping;
    }

    public String getJoinTable() {
        return joinTable;
    }

    public void setJoinTable(String joinTable) {
        this.joinTable = joinTable;
    }

    public String getJoinSourceField() {
        return joinSourceField;
    }

    public void setJoinSourceField(String joinSourceField) {
        this.joinSourceField = joinSourceField;
    }

    public String getJoinTargetField() {
        return joinTargetField;
    }

    public void setJoinTargetField(String joinTargetField) {
        this.joinTargetField = joinTargetField;
    }

    public String getJavaFiledId() {
        String javaFiledId="";
        String[] filedArr=filedId.split("_");
        for(int i=0;i<filedArr.length;i++){
            if(i==0){
                javaFiledId+=filedArr[i].substring(0, 1).toLowerCase()+filedArr[i].substring(1);
            }else{
                javaFiledId+=filedArr[i].substring(0, 1).toUpperCase()+filedArr[i].substring(1);
            }
        }
        return javaFiledId;
    }

}
